package com.kunbo.cn.controller.core.sale;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.kunbo.cn.util.retu.ReturnBean;

@RestController
@RequestMapping("/sale/")
public class SaleOrderManagerController {
	
	@Autowired
	private JdbcTemplate jdbc;
	/**
	   * 启用
	 */
	@RequestMapping("startOrder")
	public ReturnBean startOrder(String tableName ,Integer id) {
		if("".equals(tableName) || null==id) {
			return new ReturnBean(false,"参数有误，请检测");
		}
		Integer r = jdbc.update("update business_sale_order_manage set state = '4'  where id = "+id+"");
		if(r>0) {
			return new ReturnBean(true,"操作成功");
		}else {
			return new ReturnBean(false,"执行失败");
		}
		
		
	}
	/**
	   * 作废
	 */
	@RequestMapping("cancelOrder")
	public ReturnBean cancelOrder(String tableName ,Integer id) {
		if("".equals(tableName) || null==id) {
			return new ReturnBean(false,"参数有误，请检测");
		}
		Integer r = jdbc.update("update "+tableName+" set state = '5'  where id = "+id+"");
		if(r>0) {
			return new ReturnBean(true,"操作成功");
		}else {
			return new ReturnBean(false,"执行失败");
		}
		
		
	}
	/**
	   * 完成
	 */
	@RequestMapping("finishOrder")
	public ReturnBean finishOrder(String tableName ,Integer id) {
		if("".equals(tableName) || null==id) {
			return new ReturnBean(false,"参数有误，请检测");
		}
		Integer r = jdbc.update("update "+tableName+" set state = '3'  where id = "+id+"");
		if(r>0) {
			return new ReturnBean(true,"操作成功");
		}else {
			return new ReturnBean(false,"执行失败");
		}
		
		
	}

}
